
package com.sailing.lianxi.util.machine;

import java.net.InetAddress;

public class MachineTool {

    public static void getLocalIp(){
        String hostName = "";
        String hostAddress = "";
        try {
            InetAddress localhost = InetAddress.getLocalHost();
            hostName = localhost.getHostName();
            hostAddress = localhost.getHostAddress();
        } catch (Exception e) {
            hostName = "localhost";
            hostAddress = "127.0.0.1";
        }
        System.out.println("hostName="+hostName+","+hostAddress);
    }
    
    public static void main(String[] args) {
        MachineTool.getLocalIp();
    }
}

